<?php
	$controller_list = array();
	$action_list = $this->action_list;
	foreach ($this->controller_list as $controller) {
		$controller_list[$controller['id']] = $controller['name'];
	}
	echo "<form method = 'Post' name = 'main_form'>";
	echo  $this->formHidden('mode','delete');
	echo  $this->formHidden('id');
	echo  $this->formHidden('name');
	echo  $this->formHidden('controller_id');
	echo  $this->formHidden('action_txt');
	echo "</form>";
	echo $this->formButton('add-action','Thêm',array());
	echo "<table style = 'width:100%;' class = 'table table-bordered table-striped'>";
	if ($action_list){
		echo "<tr class = 'tr2'>";
		echo "<th style ='width:40px;'>STT</th>";
		echo "<th align='left'>Tên</th>";
		echo "<th align='left'>Mục</th>";
		echo "<th align='left'>Action</th>";
		echo "<th style ='width:100px;' align='center'>Sửa</th>";
		echo "<th style ='width:100px;' align='center'>Xóa</th>";
		echo "</tr>";
		$i = 1;
		foreach ($action_list as $controller_name => $action_in_controller) {
			foreach ($action_in_controller as $action) {
				echo "<tr class = 'tr" . (($i%2) + 3) . "'>";
				echo "<td align = 'center'>" . $i . "</td>";
				echo "<td>" . $action['name'] . "</td>";
				echo "<td>" . $controller_name . "</td>";
				echo "<td>" . $action['action'] . "</td>";
				echo "<td align='center'>" . $this->formButton('edit_' . $action['id'],'Sửa',array('class' => 'btn_edit edit_action','action_id' => $action['id'],'controller_id' => $action['controller_id'],'action_name' => $action['name'],'action' => $action['action'])) . "</td>";
				echo "<td align='center'>" . $this->formButton('delete_' . $action['id'],'Xóa',array('class' => 'btn_del','onclick' => 'delete_controller(' . $action['id'] . ')')) . "</td>";
				echo "</tr>";
				$i++;
			}
		}
	}else {
		echo "<tr>";
		echo "<td>Hiện chưa có dữ liệu</td>";
		echo "</tr>";
	}
	echo "</table>";
	echo "<div id='add-form' title='Thêm' style = 'display:none'>";
	echo "<table width = 400px>";
	echo "<tr>";
	echo "<td width = 100px align = 'right'>Mục : ";
	echo "</td>";
	echo "<td>";
	echo $this->formSelect('cmb_controller',0,array(),$controller_list);
	echo "</td>";
	echo "<tr>";
	echo "<td width = 100px align = 'right'>Tên : ";
	echo "</td>";
	echo "<td>";
	echo $this->formText('txt_name','',array('size' => '40'));
	echo "</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td align = 'right'>Action : ";
	echo "</td>";
	echo "<td>";
	echo $this->formText('txt_action','',array('size' => '40'));
	echo "</td>";
	echo "</tr>";
	echo "</table>";
	echo "</div>";
	
	echo "<div id='edit-form' title='Sửa' style = 'display:none'>";
	echo "<table width = 400px>";
	echo "<tr>";
	echo "<td width = 100px align = 'right'>Mục : ";
	echo "</td>";
	echo "<td>";
	echo $this->formSelect('edit_cmb_controller',0,array(),$controller_list);
	echo "</td>";
	echo "<tr>";
	echo "<td width = 100px align = 'right'>Tên : ";
	echo "</td>";
	echo "<td>";
	echo $this->formText('edit_txt_name','',array('size' => '40'));
	echo "</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td align = 'right'>Action : ";
	echo "</td>";
	echo "<td>";
	echo $this->formText('edit_txt_action','',array('size' => '40'));
	echo "</td>";
	echo "</tr>";
	echo "</table>";
	echo "</div>";
